package com.tensquare.article.rest;

import com.netflix.discovery.converters.Auto;
import com.tensquare.article.service.ArticleService;
import com.tensquare.entity.Result;
import com.tensquare.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("article")
public class ArticleRest {

    @Autowired
    ArticleService articleService;

    /**
     * http://localhost:9004/article/examine/1
     * @param id
     * @return
     */
    @RequestMapping(value = "/examine/{id}" , method = RequestMethod.GET)
    public Result examine(@PathVariable("id") String id){
        articleService.examine(id);
        return new Result(true, StatusCode.OK, "审核成功");
    }

    /**
     * 文章点赞
     * @param id
     * @return
     */
    @RequestMapping(value = "/thumbup/{id}" , method = RequestMethod.PUT)
    public Result thumbup(@PathVariable("id") String id){
        articleService.updateThumbup(id);
        return new Result(true, StatusCode.OK, "点赞成功");
    }
}
